﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IndoReputation.Models.BusinessObject;
using IndoReputation.Models.BusinessObject.Collections;
using IndoReputation.Models.DataAccess;

namespace IndoReputation.Models.BusinessLogic
{
    public class OfficeTypeBOL
    {
        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 4/22/2012  6:03 PM
        /// Todo: Insert an officeType to db
        /// </summary>
        /// <param name="officeType">The officeType.</param>
        /// <returns></returns>
        public static int Insert(OfficeType officeType)
        {
            try
            {
                officeType.CreateAt = DateTime.Now;
                officeType.CreateBy = MySession.UserID;
                officeType.UpdateAt = null;
                officeType.UpdateBy = null;
                return OfficeTypeDAL.Insert(officeType);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  9:45 AM
        /// Todo: Update a User Exists in Database 
        /// </summary>
        /// <param name="officeType">A officeType.</param>
        /// <returns></returns>
        public static bool Update(OfficeType officeType)
        {
            try
            {
                officeType.UpdateAt = DateTime.Now;
                officeType.UpdateBy = MySession.UserID;
                return OfficeTypeDAL.Update(officeType);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:36 AM
        /// Todo: Delete a User Existst in Database
        /// </summary>
        /// <param name="officeType">A officeType.</param>
        /// <returns></returns>
        public static bool Delete(int officeTypeID)
        {
            try
            {
                return OfficeTypeDAL.Delete(officeTypeID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All OfficeType
        /// </summary>
        /// <returns></returns>
        public static OfficeTypeList GetAllOfficeType()
        {
            try
            {
                return OfficeTypeDAL.GetAllOfficeType() ?? new OfficeTypeList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="officeTypeID">The officeType ID.</param>
        /// <returns></returns>
        public static OfficeType GetOfficeTypeById(int officeTypeID)
        {
            try
            {
                return OfficeTypeDAL.GetOfficeTypeById(officeTypeID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
}